{extend name="_container/add"}

{block name="content"}
<div class="layui-form-item">
    <label class="layui-form-label">应用<span></span></label>
    <div class="layui-input-inline">
        {foreach $apps as $app}
        <input type="checkbox" placeholder="" name="apps[]" id="info_app" class="layui-input modelform_name"
               title="{$app.name}" {$app.is_default?'checked':''} value="{$app.id}" style="" autocomplete="off">
        {/foreach}
        <div class="description"></div>

    </div>
    <div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">数据表<span></span></label>
    <div class="layui-input-inline">
        <table class="layui-table">
            <tr>
                <th>表中文名</th>
                <th>表英文名</th>
            </tr>
            {for start="1" end="40"}
            <tr>
                <td>
                    <input type="text" placeholder="表中文名" name="comment[]" class="layui-input"
                           style="" autocomplete="off" tabindex="{$i}" {if $i==1}id="start_focus"{/if}>
                </td>
                <td>
                    <input type="text" placeholder="表英文名" name="name[]" class="layui-input"
                           style="" autocomplete="off">
                </td>
            </tr>
            {/for}
        </table>

        <div class="description"></div>

    </div>
    <div class="layui-form-mid layui-word-aux"></div>


    {/block}
    {block name="js"}
    <script>
        function save_form3(obj) {
            save_form2(obj);
            return false;
        }
    </script>


    <script>
        let pre = "{:env('database.prefix')}";
        $("input[name='comment[]']").blur(
            function (obj) {
                let word = obj.target.value;
                if (word) {
                    $.get('/auto/util/getEnglish?word=' + word, (data) => {
                        let res = data.result;
                        $(obj.target).parents('tr').find("input[name='name[]']").val(pre + res)
                    })
                }
            }
        )
    </script>

    <script>
        $('#start_focus').focus();
    </script>
    {/block}

    {/extend}
